<?php
	require("../include/dbfunctions.php");
session_start();
	if((isset($_SESSION['time']) && $_SESSION['time']+600<time())){// || !isset($_SESSION['user'], $_SESSION['psw'], $_SESSION['idpsw'], $_GET['cid'])){
		session_destroy();
		header("Location: index.php");
	}
	$stud = new Student($_SESSION['user'],$_SESSION['psw'],$_SESSION['idpsw']);
	$cid = (int) $_GET['cid'];
	if(!$stud->attends($cid))
		die("Non puoi rispondere a questo questionario.");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta content="text/html; charset=UNICODE-1" http-equiv="Content-Type" />
	<title>PolibaMarks</title>
	<link rel="stylesheet" href="stile.css"/>
</head>

<body>
	<div id="imgLogo">
		<img id="imgLogo" src="img/logopoliba.jpg" alt="Logo" />
	</div>
	<div>
		<h2>Questionario sulla didattica</h2>
<?php  
	$data = $stud->classData($cid);
	echo "<h4>",$data[2]," - Prof. ",$data[0]," ",$data[1],"</h4>";
?>
		<form method="post">
		<table>
<?php 
		$quest = $stud->getQuestions($cid);
		foreach($quest as $q){
			echo "<tr><td>{$q[1]}</td><td><select name=\"{$q[0]}\">";
			for($i=0;$i<6;++$i)
				echo "<option value=\"{$i}\">{$i}</option>";
			echo "</select></td></tr>";
		}
?>		</table>
		<input type="submit" value="Invia"/>
		</form>
	</div>
</body>
</html>